<template>
  <AmisRenderers
    ref="renderer"
    :schema="schema"
    :permissions="user.permissions"
    :locals="locals"
    :hasRouter="hasRouter"
    :fetcher="service"
    :env="envs"
    :axios="service"
  />
</template>

<script setup>
import { applyPureReactInVue } from "veaury";
import {  AmisRenderer as AmisReactRenderer } from "custom-amis";
import { ElNotification } from "element-plus";
import { getAccessToken } from "@/utils/auth";
import download from "@/utils/download";
import { service } from "@/config/axios/fecher";
import axios from "axios";
import qs from "qs";
import "amis/sdk/sdk.js";
// import 'amis/sdk/sdk.css'
import "amis/sdk/iconfont.css";
import "amis/sdk/helper.css";
import "amis/sdk/rest.js";
import "amis/sdk/tinymce.js";
import "@fortawesome/fontawesome-free/css/all.css";
// import '@fortawesome/fontawesome-free/js/all'
import "amis/lib/themes/default.css";
import "amis/lib/helper.css";
import "amis-ui/lib/themes/antd.css";
import "amis-ui/lib/themes/cxd.css";

import { CACHE_KEY, useCache } from "@/hooks/web/useCache";

const AmisRenderers = applyPureReactInVue(AmisReactRenderer);

const props = defineProps({
  schema: {},
  locals: {
    type: Object,
    default: () => ({}),
  },
  env: {
    type: Object,
    default: () => ({}),
  },
  hasRouter: {
    type: Boolean,
    default: false,
  },
});
const { wsCache } = useCache();
const user = wsCache.get(CACHE_KEY.USER);
console.log(user)
const envs = {
  theme: "cxd",
};
const renderer = ref("renderer");
onMounted(() => {
  const $el = renderer._value.$el;
  $el.style.all = ""; // 解决样式BUG
  $el.classList.add("amis-renderer");
  if ($el.children && $el.children[0]) {
    $el.children[0].classList.add("vue-react-container");
  }
});
</script>

<style lang="scss">
@import "./index.scss";
</style>
